package me.zk.practice1.s;

import java.util.Stack;

/**
 * @author zhangkai
 * @date 2023/7/7 18:08
 */
public class LS232 {

    private static Stack<Integer> inStack;
    private static Stack<Integer> outStack;
    public LS232(){
        inStack = new Stack<>();
        outStack = new Stack<>();
    }

    public void push(int x) {
        inStack.push(x);
    }

    public int pop() {
        if (outStack.empty()){
            in2out();
        }
        return outStack.pop();
    }

    public int peek() {
       if (outStack.empty()){
           in2out();
       }
        return outStack.peek();
    }

    public boolean empty() {
        return inStack.empty()&& outStack.empty();
    }
    public void in2out(){
        while (!inStack.empty()) {
            outStack.push(inStack.pop());
        }
    }
}
